package com.malphi.framework.flash.jsonparse;

import java.util.List;

/**
 * flash data 解析方法类
 * 
 * @author mrf
 * 
 */
public class InvocationMethod {
	private String name;
	private List<InvocationParam> params;

	public InvocationMethod(String name,List<InvocationParam> params){
		this.name = name;
		this.params = params;
	}
	public List<InvocationParam> getParams() {
		return params;
	}

	public void setParams(List<InvocationParam> params) {
		this.params = params;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * 取参数的对应类型列表 
	 * 执行反射方法时使用
	 * @return
	 */
	public Class[] getParamsClass(){
		if(params.size()==0) return null;
		Class[] classArray = new Class[params.size()];
		for (int i = 0; i < params.size(); i++) {
			classArray[i] = FlashDataType.getClassByCode(params.get(i).getTypeCode());
		}
		return classArray;
	}
	
	/**
	 * 取参数值列表
	 * @return
	 */
	public Object[] getParamValues(){
		if(params.size()==0) return null;
		Object[] values = new Object[params.size()];
		for (int i = 0; i < params.size(); i++) {
			values[i] = params.get(i).getValue();
		}
		return values;
	}
	
	@Override
	public String toString(){
		return "InvocationMethod: name="+name+" , params=" +params;
	}

}
